import cv2
import matplotlib.pyplot as plt
import numpy as np

if __name__ == "__main__":
    img_gray = cv2.imread("../images/Camera_A_1.jpg", cv2.IMREAD_GRAYSCALE)
    _, thresh_01 = cv2.threshold(img_gray, 127, 255, cv2.THRESH_BINARY)
    _, thresh_02 = cv2.threshold(img_gray, 127, 255, cv2.THRESH_BINARY_INV)
    _, thresh_03 = cv2.threshold(img_gray, 127, 255, cv2.THRESH_TRUNC)
    _, thresh_04 = cv2.threshold(img_gray, 127, 255, cv2.THRESH_TOZERO)
    _, thresh_05 = cv2.threshold(img_gray, 127, 255, cv2.THRESH_TOZERO_INV)
    title = ["Original", "THRESH_BINARY", "THRESH_BINARY_INV",
             "THRESH_TRUNC", "THRESH_TOZERO", "THRESH_TOZERO_INV"]
    img = [img_gray, thresh_01, thresh_02, thresh_03, thresh_04, thresh_05]
    for i in range(len(title)):
        plt.subplot(2, 3, i + 1)
        plt.imshow(img[i], "gray")
        plt.title(title[i])
        plt.xticks([])
        plt.yticks([])
    plt.show()
